home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Roaster-Java-WA-HTTP-CGI hack / cgi WA plugin / Interfaces / ModuleSupport.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  2.7 KB  |  96 lines  |  [TEXT/MPS ]

  1. #ifndef MODULESUPPORT_H
  2. #define MODULESUPPORT_H
  3.  
  4. /* This file defines some utility types, functions, and macros used in
  5.  * Module.h and files which depend on it.
  6.  */
  7.  
  8. #include    <Types.h>
  9. #include    <Quickdraw.h>
  10. #include    <Files.h>
  11. #include <stddef.h>
  12.  
  13.  
  14. /* These macros are used to specify the usage of parameters passed by
  15.  * reference or as a pointer.
  16.  */
  17. #undef  IN
  18. #undef  OUT
  19. #undef  IO
  20. #define IN    // parameter is read-only (equivalent to const).
  21. #define OUT // parameter is write-only.
  22. #define IO    // parameter is both read and written.
  23.  
  24.  
  25. /* This macro is used in front of a pointer declaration to indicate that
  26.  * the object pointed to is "owned" by the object containing the declaration
  27.  * (i.e. will be disposed of by the object's destructor).  When used in front
  28.  * of a parameter or function result declaration, it indicates that ownership
  29.  * of the pointer is being transferred into or out of the function.
  30.  */
  31. #undef OWN
  32. #define OWN
  33.  
  34.  
  35. /* These standard types are used to represent 32-bit, 16-bit, and 8-bit
  36.  * integers; characters; and double-precision floating point values.  Note
  37.  * that “Byte” with no u or s prefix is unsigned, even though “Short” and
  38.  * “Integer” are signed; this is mainly for compatability with types.h, which
  39.  * defines Byte as unsigned char.
  40.  */
  41. typedef signed long        Integer;
  42. typedef unsigned long        uInteger;
  43. typedef signed short        Short;
  44. typedef unsigned short    uShort;
  45. typedef unsigned char    Byte;
  46. typedef signed char        sByte;
  47. typedef unsigned char    Character;
  48. typedef double                Float;
  49.  
  50. typedef void*         voidPtr;
  51. typedef Integer*     IntegerPtr;
  52. typedef uInteger*     uIntegerPtr;
  53. typedef Short*         ShortPtr;
  54. typedef uShort*     uShortPtr;
  55. typedef Byte*         BytePtr;
  56. typedef sByte*         sBytePtr;
  57. typedef Character* CharacterPtr;
  58. typedef Float*         FloatPtr;
  59.  
  60.  
  61. inline Integer Min(Integer a, Integer b) { return (a<b ? a : b); }
  62. inline Integer Max(Integer a, Integer b) { return (a>b ? a : b); }
  63.  
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. extern void DebugMsg(const char* msg);
  70.  
  71. #ifdef __cplusplus
  72. }
  73.  
  74. /* This mess exists to define the Assert macro.  Assert takes one parameter which
  75.  * should be an expression that evaluates to a boolean result.  If the result is
  76.  * true, it does nothing; if the result is false, it traps to the debugger with
  77.  * a message of the form “Assertion failed: ‘foo >= 0’”, where foo >= 0 is
  78.  * replaced by whatever your expression was.  If the ModuleDebug flag is turned
  79.  * off, no object code is created for Assert calls.
  80.  */
  81. #if ModuleDebug
  82.     inline void AssertMsg(Boolean assertion, const char* message)
  83.         {
  84.         if (!assertion)
  85.             DebugMsg((char*)message);
  86.         }
  87.     #define Assert(x) AssertMsg(x, "Assertion failed: “" #x "”")
  88. #else
  89.     #define AssertMsg(x,y)
  90.     #define Assert(x)
  91. #endif
  92.  
  93. #endif // __cplusplus
  94.  
  95. #endif // ifndef MODULESUPPORT_H
  96.